<script setup lang="ts">
import Sub from "./Sub.vue";
import {ref} from "vue";
/* sub 调用 top void 方法*/
const dealIsOk = () => {
  alert('sub call top void')
}
/* sub 调用 top args 方法*/
const doSendData = (e: string) => {
  alert(`sub call top send: ${e} `)
}

/* top 调用 sub 方法*/
const subRef = ref<InstanceType<typeof Sub> | null>(null)
const callSub = () => {
  if (subRef.value) {
    subRef.value.dosth('top call sub')
  }
}

</script>

<template>
  <h3> Top content </h3>
  <button @click="callSub">callSub</button>
  <br>
  *************************<br>
  <Sub
      ref="subRef"
      msg="tom" :age="12"
      @isOk="dealIsOk"
      @sendData="doSendData"
  />

</template>

<style scoped>
</style>
